using System.ComponentModel.DataAnnotations;
using VotingSystem.Models;

namespace VotingSystem.ViewModels
{
    public class SurveyCreateViewModel
    {
        public int? Id { get; set; }

        [Required(ErrorMessage = "请输入问卷标题")]
        [StringLength(100, ErrorMessage = "标题长度不能超过100个字符")]
        public string Title { get; set; } = string.Empty;

        [Required(ErrorMessage = "请输入问卷说明")]
        public string Description { get; set; } = string.Empty;

        public DateTime? EndTime { get; set; }

        public bool IsAnonymous { get; set; }

        public bool IsPublic { get; set; }

        public bool AllowMultipleSubmissions { get; set; } = true;

        public string CreatorId { get; set; } = string.Empty;

        public List<QuestionViewModel> Questions { get; set; } = new List<QuestionViewModel>();

        public SurveyCreateViewModel()
        {
            Questions = new List<QuestionViewModel>();
        }
    }

    public class QuestionViewModel
    {
        public int? Id { get; set; }

        public int Order { get; set; }
        
        [Required(ErrorMessage = "请输入问题内容")]
        public string QuestionText { get; set; } = string.Empty;
        
        [Required(ErrorMessage = "请选择问题类型")]
        public QuestionType Type { get; set; }
        
        public bool IsRequired { get; set; }
        
        public List<QuestionOptionViewModel> Options { get; set; } = new List<QuestionOptionViewModel>();

        // 多选题选择限制
        public int? MinSelectionCount { get; set; }
        public int? MaxSelectionCount { get; set; }
        public int? ExactSelectionCount { get; set; }

        // 评分题特有属性
        public int? MinScore { get; set; }
        public int? MaxScore { get; set; }
        public string ScoreLabels { get; set; } = string.Empty;

        // 文件上传题特有属性
        public string AllowedFileTypes { get; set; } = string.Empty;
        public int? MaxFileSize { get; set; }

        // 简答题特有属性
        public int? MaxLength { get; set; }

        // 数值题特有属性
        public decimal? MinValue { get; set; }
        public decimal? MaxValue { get; set; }

        // 矩阵题特有属性
        public List<string> RowTitles { get; set; } = new List<string>();
        public List<string> ColumnTitles { get; set; } = new List<string>();

        public QuestionViewModel()
        {
            Options = new List<QuestionOptionViewModel>();
            RowTitles = new List<string>();
            ColumnTitles = new List<string>();
        }
    }
} 